package com.springboot.thymeleaf.controller;

import com.springboot.thymeleaf.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Controller
public class ThymeleafController {

    @GetMapping("/hello")
    public String hello(Model model){
        model.addAttribute("username","<h1>xiehao</h1>");
        model.addAttribute("sex",1);
        model.addAttribute("city","changsha");

        User user1=new User(1,"李白","123");
        User user2=new User(2,"杜甫","123");
        List<User> users=new ArrayList<>();
        users.add(user1);
        users.add(user2);
        model.addAttribute("users",users);
        model.addAttribute("date",new Date());
        return "hello";
    }

    @GetMapping("/login")
    public String login(String username,String pass){
        System.out.println(username);
        System.out.println(pass);
        System.out.println("exec login()");
        return "hello";
    }
}


